import type { dialogData } from '../../shares/sharesApp';
import plots from './JSON/plot.json';

export const points: GameEntity[] = world
  .querySelectorAll('*')
  .filter((e) => e.id.startsWith('旋转圆圈-'));

points.forEach((e) => {
  e.onEntityContact(({ other }) => {
    if (other.point === e) {
      return;
    }
    if (other.player) {
      remoteChannel.sendClientEvent(other as GamePlayerEntity, <dialogData>{
        type: 'dialog',
        data: e.id,
      });
    }
  });
});

world.onPlayerJoin(({ entity }: GamePlayerEntityEvent) => {
  remoteChannel.sendClientEvent<dialogData>(entity, <dialogData>{
    type: 'dialog',
    data: 'start',
  });
});

const tower: GameEntity = world.querySelector('#冰系魔法塔')!;
tower.onInteract(({ entity }) => {
  remoteChannel.sendClientEvent<dialogData>(entity, <dialogData>{
    type: 'dialog',
    data: 'end',
  });
});
